package com.su.dolphin.core.proxy;

import java.io.IOException;
import java.util.HashMap;

import com.su.dolphin.utils.DpHttpUtil;
import com.su.dolphin.utils.LogUtil;

/**
 * 框架与xutils等工具类的代理, 便于替换xutil afinal等框架
 * 
 * @author gaoshuai
 * 
 */
public class HttpProxy {
	private static HttpProxy sHttpUtilProxy;

	public static HttpProxy i() {
		if (sHttpUtilProxy == null) {
			sHttpUtilProxy = new HttpProxy();
		}
		return sHttpUtilProxy;
	}

	public String get(String url) {
		//LogUtil.i("get url ==> " + url);
		try {
			String result = DpHttpUtil.get(url);
			//LogUtil.i("result  ==> " + result);
			return result;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}

	public String get(String url, HashMap<String, String> params) {
		//LogUtil.i("get url ==> " + DpHttpUtil.appendQueryParams(url, params));
		try {
			String result = DpHttpUtil.get(url, params);
			//LogUtil.i("result  ==> " + result);
			return result;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}

	public String post(String url, HashMap<String, String> params) {
		//LogUtil.i("post url ==> " + DpHttpUtil.appendQueryParams(url, params));
		try {
			String result = DpHttpUtil.postForm(url, params);
			//LogUtil.i("result  ==> " + result);
			return result;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
}
